package com.xkstream.client.ui.live.fragment;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.xkstream.client.R;
import com.xkstream.client.base.BaseFragment;
import com.zego.zegoliveroom.constants.ZegoBeauty;

import butterknife.BindView;
import butterknife.OnClick;

import static com.xkstream.client.application.Application.mZegoLiveRoom;

/**
 * Created by xiaoyi on 2017-11-20.
 */

public class LiveActionFragment extends BaseFragment {
    @BindView(R.id.llBeauty)
    LinearLayout llBeauty;

    int beauty = 3;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_live_action;
    }

    @Override
    public void initViews(View root) {

    }

    @OnClick({R.id.ivBeauty})
    public void onClick(View view){
        switch (view.getId()){
            case R.id.ivBeauty:
                showChooseBeauty();
                break;
        }
    }

    private void showChooseBeauty() {
        if (llBeauty.getVisibility() == View.VISIBLE){
            llBeauty.setVisibility(View.GONE);
            return;
        }
        llBeauty.setVisibility(View.VISIBLE);
        for (int i = 0; i < llBeauty.getChildCount(); i++) {
            TextView child = (TextView) llBeauty.getChildAt(i);
            if (i == beauty) {
                child.setTextColor(getResources().getColor(R.color.money_selected));

            } else {
                child.setTextColor(getResources().getColor(R.color.login_input_selected));
            }
            int index = i;
            child.setOnClickListener((v) -> {
                changeBeauty(index);
                llBeauty.setVisibility(View.GONE);
            });
        }
    }

    private void changeBeauty(int index) {
        beauty = index;
        switch (index) {
            case 0:
                mZegoLiveRoom.enableBeautifying(ZegoBeauty.NONE);
                break;
            case 1:
                mZegoLiveRoom.enableBeautifying(ZegoBeauty.POLISH);
                break;
            case 2:
                mZegoLiveRoom.enableBeautifying(ZegoBeauty.WHITEN);
                break;
            case 3:
                mZegoLiveRoom.enableBeautifying(ZegoBeauty.POLISH | ZegoBeauty.WHITEN);
                break;
            case 4:
                mZegoLiveRoom.enableBeautifying(ZegoBeauty.POLISH | ZegoBeauty.SKIN_WHITEN);
                break;
        }
    }
}
